package com.libre.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.libre.system.entity.Dict;
import com.libre.system.mapper.DictMapper;
import com.libre.system.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
* @description   字典
* @author        庞留杰
* @date          2021/12/20 22:59
* @version       V1.0
**/
@Transactional
@Slf4j
@Service
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements DictService {

    @Override
    public IPage<Dict> findPage(Page initMpPage, Dict dict) {
        QueryWrapper<Dict> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete","0");
        return this.page(initMpPage,queryWrapper);
    }

    @Override
    public List<Dict> findList(Dict dict) {
        QueryWrapper<Dict> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete","0");
        List<Dict> list = this.list(queryWrapper);
        return list;
    }

    @Override
    public Dict findById(String id) {
        return this.getById(id);
    }

    @Override
    public boolean add(Dict dict) {
        return this.save(dict);
    }

    @Override
    public boolean update(Dict dict) {
        return this.updateById(dict);
    }

    @Override
    public boolean delete(String id) {
        Dict dict = new Dict();
        dict.setId(id);
        dict.setIsDelete("1");
        return this.updateById(dict);
    }
}
